package com.linln.admin.meeting.domain;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.linln.common.utils.StatusUtil;
import com.linln.modules.system.domain.User;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * @author taofucheng
 * @date 2021/10/25
 */
@Data
@Entity
@Table(name="meeting_room")
@EntityListeners(AuditingEntityListener.class)
@Where(clause = StatusUtil.NOT_DELETE)
@DynamicInsert
@DynamicUpdate
public class Room implements Serializable {
    //
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name="`id`")
    private Long id;
    // 分组信息
    @Column(name="`group_id`")
    private Long groupId;
    // 会议室名称
    @Column(name="`title`")
    private String title;
    // 位置
    @Column(name="`position`")
    private String position;
    // 容纳人数
    @Column(name="`volume`")
    private Long volume;
    // 提供的设备
    @Column(name="`devices`")
    private String devices;
    // 是否有窗户
    @Column(name="`window`")
    private String window;
    // 其它
    @Column(name="`other`")
    private String other;
    // 创建时间
    @CreatedDate
    @Column(name="`create_date`")
    private Date createDate;
    // 更新时间
    @LastModifiedDate
    @Column(name="`update_date`")
    private Date updateDate;
    // 创建用户
    @CreatedBy
    @ManyToOne(fetch=FetchType.LAZY)
    @NotFound(action=NotFoundAction.IGNORE)
    @JoinColumn(name="create_by")
    @JsonIgnore
    @JSONField(serialize = false)
    private User createBy;
    // 更新用户
    @LastModifiedBy
    @ManyToOne(fetch=FetchType.LAZY)
    @NotFound(action=NotFoundAction.IGNORE)
    @JoinColumn(name="update_by")
    @JsonIgnore
    @JSONField(serialize = false)
    private User updateBy;
    // 状态
    @Column(name="`status`")
    private Short status;
}